<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>留言板</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            margin: auto;
            width: 800px;
            height: 700px;
            
            border: 5px solid honeydew;
            /* background-color: antiquewhite; */
        }
        ul,li{
     list-style-type: none;
 }
        ul{
            width: 500px;height: 300px;
            border: 1px solid powderblue;
            text-align: center;
            margin: 10px auto;
            overflow: scroll;
            
        }
        #box2{
            width: 400px;
            height: 200px;
            text-align: center;
            border-radius: 10px;
            border: 1px dashed rgb(187, 239, 144 );
            margin-left: 26%;
            
            
        }
    </style>
</head>
<body>
    <div class="box">
        <h1 style="font: size 50px;;color:plum;text-align: center;">留言板</h1>
        <ul ></ul>
        <textarea name="ly" id="box2" placeholder="请输入留言内容"></textarea>
        <button style="width: 80px;background-color:paleturquoise;">留言</button>
    </div>
</body>
<script>
    let btn=document.querySelector('button');
   let text=document.querySelector('#box2');
    let ul=document.querySelector('ul');
    btn.onclick=function(evt){
   let li=document.createElement('li');
         li.innerHTML=text.value;
         ul.insertBefore(li,ul.children[0]);
         text.value=null;
         evt.stopPropagation();
  // }
  };
</script>

</body>
</html>